<template>
    <div style="margin-top: 15px; width:600px;">
        <el-input placeholder="请输入内容" v-model="input" class="input-with-select">
            <el-select v-model="select" slot="prepend" placeholder="请选择">
                <el-option label="商品" value="1"></el-option>
                <el-option label="店铺" value="2"></el-option>


            </el-select>
            <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
        </el-input>
    </div>
</template>

<script>

    export default  {
        data() {
            return {
                input: '',
                select: '1'
            }
        },
        name: 'SearchBar',
        props: {

        },
        created() {


        },
        methods:{
            search(){
                if(this.select == "1"){
                    this.$store.dispatch("getSearchCommodityData",{page:0,pageSize:12,title:this.input})
                }else if(this.select == "2"){
                    this.$store.dispatch("getSearchShopNameData",{page:0,pageSize:12,Name:this.input})
                }


                if(this.$route.path == "/Search"){
                    return ""
                }else{
                    this.$router.push("/Search");
                }

            }

        }
    }
</script>

<style>
    .el-select .el-input {
        width: 130px;
    }
    .input-with-select .el-input-group__prepend {
        background-color: #fff;
    }
</style>